package com.yunkaweilai.android.view.dialog.operation;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.TextView;

import com.flyco.dialog.utils.CornerUtils;
import com.flyco.dialog.widget.base.BaseDialog;
import com.yunkaweilai.android.R;
import com.yunkaweilai.android.interfaces.DialogPayInterface;
import com.yunkaweilai.android.utils.Utils;

/**
 * 确认付款
 * Created by Administrator on 2016/12/22 0022.
 */

public class OperationPayCashDialog extends BaseDialog<OperationPayCashDialog> {
    private TextView idTvContent;
    private TextView idTvClose;
    private TextView idTvRight;
    private String Actualmoney;
    private String Receivablesmoney;
    private DialogPayInterface dialogPayInterface;
    private TextView idTvOtherContent;

    public OperationPayCashDialog(Context context, String Actualmoney, String Receivablesmoney, DialogPayInterface dialogPayInterface) {
        super(context);
        this.Actualmoney = Actualmoney;
        this.Receivablesmoney = Receivablesmoney;
        this.dialogPayInterface = dialogPayInterface;
    }

    @Override
    public View onCreateView() {
        widthScale(0);
        //showAnim(new Swing());
        //dismissAnim(this, new ZoomOutExit());
        View inflate = View.inflate(mContext, R.layout.dialog_operation_pay_cash, null);
        idTvContent = ((TextView) inflate.findViewById(R.id.id_tv_content));
        idTvRight = ((TextView) inflate.findViewById(R.id.id_tv_right));
        idTvClose = (TextView) inflate.findViewById(R.id.id_tv_close);
        idTvOtherContent = ((TextView) inflate.findViewById(R.id.id_tv_ohter_content));
        String zhaoling = Float.parseFloat(Receivablesmoney) - Float.parseFloat(Actualmoney) + "";
        idTvOtherContent.setText("收款：" + Receivablesmoney + "，找零：" + Utils.ManageMoney(zhaoling));
        idTvContent.setText("￥ " + Actualmoney);


        //设置背景颜色，和背景的透明圆弧角度
        inflate.setBackgroundDrawable(
                CornerUtils.cornerDrawable(Color.parseColor("#f8f9fa"), dp2px(10)));

        return inflate;
    }

    @Override
    public void setUiBeforShow() {
        idTvRight.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialogPayInterface.payMoney();
                dismiss();
            }
        });
        idTvClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }


}
